#include <cctype>
#include <string.h>
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <map>

using namespace std;

bool is_alpha(string & word){
    for(auto & s : word){
        if(!isalpha(s)){
            return false;
        }
    }
    return true;
}

class Dictionary{
public:
    void read(const string & filename){
        ifstream ifs(filename);
        if(!ifs){
            cerr << "file is not found" << endl;
            return;
        }
        string word;
        while(ifs >> word){
            if(is_alpha(word)){
                ++_dict[word];
            }
        }
    }

    void store(const string & filename){
        ofstream ofs(filename);
        for(auto & ele : _dict){
            ofs << ele.first << " " << ele.second << endl;
        }
    }

private:
    map<string,int> _dict;
};

void test(){
    Dictionary dict;
    dict.read("The_Holy_Bible.txt");
    dict.store("bible2.txt");
}

int main()
{
    test();
    return 0;
}

